package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.admin.domain.TdmBaoJianShengWu;
import com.ruoyi.web.admin.service.ITdmBaoJianShengWuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 保健生物制剂Controller
 * 
 * @author ly
 * @date 2022-03-10
 */
@RestController
@RequestMapping("/admin/tdm_bao_jian_sheng_wu")
public class TdmBaoJianShengWuController extends BaseController
{
    @Autowired
    private ITdmBaoJianShengWuService tdmBaoJianShengWuService;

    /**
     * 查询保健生物制剂列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_bao_jian_sheng_wu:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmBaoJianShengWu tdmBaoJianShengWu)
    {
        startPage();
        List<TdmBaoJianShengWu> list = tdmBaoJianShengWuService.selectTdmBaoJianShengWuList(tdmBaoJianShengWu);
        return getDataTable(list);
    }

    /**
     * 导出保健生物制剂列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_bao_jian_sheng_wu:export')")
    @Log(title = "保健生物制剂", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmBaoJianShengWu tdmBaoJianShengWu)
    {
        List<TdmBaoJianShengWu> list = tdmBaoJianShengWuService.selectTdmBaoJianShengWuList(tdmBaoJianShengWu);
        ExcelUtil<TdmBaoJianShengWu> util = new ExcelUtil<TdmBaoJianShengWu>(TdmBaoJianShengWu.class);
        util.exportExcel(response, list, "保健生物制剂数据");
    }

    /**
     * 获取保健生物制剂详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_bao_jian_sheng_wu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmBaoJianShengWuService.selectTdmBaoJianShengWuById(id));
    }

    /**
     * 新增保健生物制剂
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_bao_jian_sheng_wu:add')")
    @Log(title = "保健生物制剂", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmBaoJianShengWu tdmBaoJianShengWu)
    {
        return toAjax(tdmBaoJianShengWuService.insertTdmBaoJianShengWu(tdmBaoJianShengWu));
    }

    /**
     * 修改保健生物制剂
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_bao_jian_sheng_wu:edit')")
    @Log(title = "保健生物制剂", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmBaoJianShengWu tdmBaoJianShengWu)
    {
        return toAjax(tdmBaoJianShengWuService.updateTdmBaoJianShengWu(tdmBaoJianShengWu));
    }

    /**
     * 删除保健生物制剂
     */
//    @PreAuthorize("@ss.hasPermi('admin:tdm_bao_jian_sheng_wu:remove')")
    @Log(title = "保健生物制剂", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmBaoJianShengWuService.deleteTdmBaoJianShengWuByIds(ids));
    }
}
